<template>
  <div class="comment-reply">
    <van-nav-bar
        :title="comment.reply_count>0?`${comment.reply_count}条回复`:'暂无回复'"
    >
    <van-icon slot="left" name="cross" @click="$emit('closeReplyShow')"></van-icon>
    </van-nav-bar>
    <div class="scrll-warp">
      <comment-item  :comment="comment"/>

      <van-cell title="全部回复"></van-cell>
      
      <comment-list :list="commentList" :source="comment.com_id" type="c"></comment-list>
        
      <!-- 发布评论回复按钮 -->
      <div class="post-warp">
        <van-button class="post-btn" round size="small" @click="isPostShow=true">回复评论</van-button>
      </div>
    </div>

    <!-- 回复评论弹窗 -->
    <van-popup v-model="isPostShow" position="bottom">
      <comment-post
      :target="comment.com_id"
      @post-success="onPostSuccess"
      ></comment-post>
    </van-popup>



  </div>
</template>
<script>
import CommentItem from './comment-item.vue'
import CommentList from './comment-list.vue'
import CommentPost from './comment-post.vue'

export default {
  name:"CommentReply",
  components:{
    CommentItem,
    CommentList,
    CommentPost
    },
  props:{
    comment:{
      type:Object,
      required:true
    }
  },
  data(){
    return {
      isPostShow:false,
      commentList:[]
    }
  },
  computed:{},
  watch:{},
  methods:{
    onPostSuccess(data){
      this.isPostShow=false
      this.comment.reply_count++
      this.commentList.unshift(data.new_obj)
    }
  }
}
</script>
<style lang="less" scoped>
.scrll-warp{
  position: fixed;
  top:220px;
  left: 0;
  right: 0;
  bottom: 88px;
  overflow: auto;
}
.post-warp{
  height: 88px;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border-top: 1px solid #d8d8d8;
  .post-btn{
    width: 60%;


  }
}
</style>